﻿@model AMAP.Areas.Supplier.Models.Account.SupplierAccountCreateViewModel
@{
    ViewBag.Title = "Devenir fournisseur";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

<h2>Créez votre compte fournisseur</h2>

<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>

@if (Model.ClosestAmap != null)
{
    AMAP.Domain.Amap Closest = Model.ClosestAmap;
    AMAP.Domain.Amap WantedAmap = Model.WantedAmap;
    AMAP.Domain.Supplier Supplier = Model.FailSupplier;
    <p>Nous avons bien pris en considération votre demande mais sommes au regret de vous annoncer qu'il existe une AMAP plus proche de chez vous.</p>
    <p>En effet, @Closest.Name est située à <strong>@(((double)AMAP.GeoCoder.GetDistance(Supplier.User.Coordinates, (AMAP.Domain.Amap)Closest)).ToString("N")) km</strong> alors que l'AMAP @WantedAmap.Name est située à <strong>@(((double)AMAP.GeoCoder.GetDistance(Supplier.User.Coordinates, (AMAP.Domain.Amap)WantedAmap)).ToString("N")) km</strong>.</p>
    <p>
        Détail de l'adresse :
    </p>
    <ul style="list-style: none;">
        <li>@Closest.Name</li>
        <li>@Closest.Address1</li>
        @if (!string.IsNullOrEmpty(@Closest.Address2))
        { 
            <li>@Closest.Address2</li>
        }
        <li>@Closest.PostalCode @Closest.City</li>
        <li>Tél. : @Closest.PhoneNumber.ToFrenchPhoneNumber()</li>
    </ul>
    <p>Association immatriculée sous le numéro @Closest.RNA</p>
}
else
{
    using (Html.BeginForm())
    {
        Html.ValidationSummary(true);
    <fieldset>
        <legend>Identifiants de connexion</legend>

        <div class="editor-label">
            @Html.LabelFor(model => model.Email)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Email)
            @Html.ValidationMessageFor(model => model.Email)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.Password)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Password)
            @Html.ValidationMessageFor(model => model.Password)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.PasswordConfirmation)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.PasswordConfirmation)
            @Html.ValidationMessageFor(model => model.PasswordConfirmation)
        </div>

    </fieldset>
    <fieldset>
        <legend>Informations personnelles</legend>

        <div class="editor-label">
            @Html.LabelFor(model => model.LastName)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.LastName)
            @Html.ValidationMessageFor(model => model.LastName)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.FirstName)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.FirstName)
            @Html.ValidationMessageFor(model => model.FirstName)
        </div>

    </fieldset>
    <fieldset>
        <legend>Informations sur la société</legend>

        <div class="editor-label">
            @Html.LabelFor(model => model.SIRET)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.SIRET)
            @Html.ValidationMessageFor(model => model.SIRET)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.CompanyName)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.CompanyName)
            @Html.ValidationMessageFor(model => model.CompanyName)
        </div>

    </fieldset>
    <fieldset>
        <legend>Coordonnées de la société</legend>

        <div class="editor-label">
            @Html.LabelFor(model => model.Address1)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Address1)
            @Html.ValidationMessageFor(model => model.Address1)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.Address2)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Address2)
            @Html.ValidationMessageFor(model => model.Address2)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.PostalCode)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.PostalCode)
            @Html.ValidationMessageFor(model => model.PostalCode)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.City)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.City)
            @Html.ValidationMessageFor(model => model.City)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.PhoneNumber)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.PhoneNumber)
            @Html.ValidationMessageFor(model => model.PhoneNumber)
        </div>
    </fieldset>
    <p>
        <input type="submit" value="Créer mon compte" />
    </p>
    }
}
